function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null)
		return unescape(r[2]);
	return null;
}
$("#clubBtn").click(function() {
	var clubName = $.trim($('#clubName').val());
	var clubAbout = $.trim($('#clubAbout').val());
	var clubId = getQueryString('clubId');
	if (clubName == "" || clubAbout == "") {
		$('#error').text('信息不能为空').show();
		return;
	} else {
		$.ajax({
			url :localhost +  "club/updateClub",
			dataType : "jsonp",
			data : {
				clubAbout : clubAbout,
				clubName : clubName,
				clubId : clubId
			},
			jsonp : "jsonpCallback",
			success : function(data) {
				if (data <= 0) {
					$("#error").html("*修改失败*");
				} else {
					$("#error").html("*修改成功*");
				}
			}
		});
	}
})
$("#manamgerBtn").click(function() {
	var managerUserId = $.trim($('#managerUserId').val());
	var clubId = getQueryString('clubId');
	if (managerUserId == "") {
		$('#error').text('信息不能为空').show();
		return;
	} else {
		$.ajax({
			url :localhost +  "managerClub/updatManagerUser",
			dataType : "jsonp",
			data : {
				managerUserId : managerUserId,
				clubId : clubId
			},
			jsonp : "jsonpCallback",
			success : function(data) {
				if (data <= 0) {
					$("#error").html("*添加失败*");
				} else {
					$("#error").html("*添加成功*");
				}
			}
		});
	}
});
$(document).ready(function() {
	$.ajax({
		url :localhost +  "club/getClub",
		dataType : "jsonp",
		jsonp : "jsonpCallback",
		data : {
			clubId : getQueryString('clubId')
		},
		success : function(data) {
			if (data != null && data != "") {
				$('#clubName').val(data.clubName);
				$('#clubAbout').val(data.clubAbout);
			} else {
				window.location.href = "sign-in.shtml";
			}
		}
	});

});